{% extends "base.html" %}
{% load i18n %}
{% load user_timezone %}

{% block body %}
<table width="100%" cellspacing="0" cellpadding="0">
  <tr>
    <td valign="top">
      <table width="100%" cellspacing="5" cellpadding="5">
      <tr>
        <td align="right">
          [<a href="/f/{{ forum.key.id }}/">{% trans "Back" %}</a>]
        </td>
      </tr>
        <!-- Original Post -->
        {% if post %}
          <tr bgcolor="#CCDDEE">
            <td>{{ post.title }}</td>
          </tr>
          <tr><td class="postcontents">{{ post.contents|safe|linebreaksbr }}</td></tr>
          <tr>
            <td align="right">
              {% if not post.is_locked or admin_mode %}
                [<a href="/p/reply/{{ post.key.id }}">{% trans "Reply" %}</a>]
              {% endif %}
              {% ifequal post.author current_club_user %}
                [<a href="/p/edit/{{ post.key.id }}">{% trans "Edit" %}</a>]
              {% endifequal %}
              {% if admin_mode %}
                {% ifnotequal post.author current_club_user %}
                  [<a href="/p/edit/{{ post.key.id }}">{% trans "Edit" %}</a>]
                {% endifnotequal %}
                {% if post.is_pinned %}
                  [<a href="/p/pin/{{ post.key.id }}">{% trans "Unpin" %}</a>]
                {% else %}
                  [<a href="/p/pin/{{ post.key.id }}">{% trans "Pin" %}</a>]
                {% endif %}
                {% if post.is_recommended %}
                  [<a href="/p/recommend/{{ post.key.id}}">{% trans "Cancel Recommendation" %}</a>]
                {% else %}
                  [<a href="/p/recommend/{{ post.key.id}}">{% trans "Recommend" %}</a>]
                {% endif %}
                {% if post.is_locked %}
                  [<a href="/p/lock/{{ post.key.id }}">{% trans "Unlock" %}</a>]
                {% else %}
                  [<a href="/p/lock/{{ post.key.id }}">{% trans "Lock" %}</a>]
                {% endif %}
                {% if post.is_deleted %}
                  [<a href="/p/delete/{{ post.key.id }}">{% trans "Undelete" %}</a>]
                {% else %}
                  [<a href="/p/delete/{{ post.key.id }}">{% trans "Delete" %}</a>]
                {% endif %}
              {% endif %}
              <!-- [{% trans "Report Abuse" %}] -->
            </td>
          </tr>
          <tr>
            <td>
              --
              <a href="/u/{{ post.author.key.name }}">
                {% if post.author.nickname %}
                  {{ post.author.nickname }}
                {% endif %}
                [{{ post.author.user.email|slice:":6" }}...]
              </a>
              <span class="time">
                ({{ post.post_time|user_timezone:time_zone|date:"Y-m-d H:i:s" }})
              </span>
            </td>
          </tr>
          {% if post.author.signature %}
            <tr>
              <td>
                <font color="gray">{{ post.author.signature|safe|linebreaksbr }}</font>
              </td>
            </tr>
          {% endif %}
        {% endif %}
        <!-- Replies -->
        {% for reply in replies %}
          <tr bgcolor="#DDEEFF">
            <td>{{ reply.title }}</td>
          </tr>
          <tr><td class="postcontents">{{ reply.contents|safe|linebreaksbr }}</td></tr>
          <tr>
            <td align="right">
              {% if not reply.root_post.is_locked or admin_mode %}
                [<a href="/p/reply/{{ reply.key.id }}">{% trans "Reply" %}</a>]
              {% endif %}
              {% ifequal reply.author current_club_user %}
                [<a href="/p/edit/{{ reply.key.id }}">{% trans "Edit" %}</a>]
              {% endifequal %}
              {% if admin_mode %}
                {% ifnotequal reply.author current_club_user %}
                  [<a href="/p/edit/{{ reply.key.id }}">{% trans "Edit" %}</a>]
                {% endifnotequal %}
                {% if reply.is_deleted %}
                  [<a href="/p/delete/{ reply.key.id }}">{% trans "Undelete" %}</a>]
                {% else %}
                  [<a href="/p/delete/{{ reply.key.id }}">{% trans "Delete" %}</a>]
                {% endif %}
              {% endif %}
              <!-- [{% trans "Report Abuse" %}] -->
            </td>
          </tr>
          <tr>
            <td>
              --
              <a href="/u/{{ reply.author.key.name }}">
                {% if reply.author.nickname %}
                  {{ reply.author.nickname }}
                {% endif %}
                [{{ reply.author.user.email|slice:":6" }}...]
              </a>
              <span class="time">
                ({{ reply.post_time|user_timezone:time_zone|date:"Y-m-d H:i:s" }})
              </span>
            </td>
          </tr>
          {% if reply.author.signature %}
            <tr>
              <td>
                <font color="gray">{{ reply.author.signature|safe|linebreaksbr }}</font>
              </td>
            </tr>
          {% endif %}
        {% endfor %}
        {% if next_index %}
        <tr>
          <td align="right">
            <a href="/t/{{ forum.key.id }}/{{ post.key.id }}/{{ next_index }}">
              {% trans "Next Page" %}
            </a>
          </td>
        </tr>
        {% endif %}
        <tr>
        <td align="right">
          [<a href="/f/{{ forum.key.id }}/">{% trans "Back" %}</a>]
        </td>
      </tr>
      </table>
    </td>
    <td valign="top" width="170">
      <table cellspacing="5" class="sidebox" width="100%">
        <tr><td class="header">{% trans "Recommendations" %}</td></tr>
        {% for post in forum.get_recommended_threads %}
          <tr><td><a href="/t/{{ post.key.id }}/">{{ post.title }}</a></td></tr>
        {% endfor %}
      </table>
    </td>
  </tr>
</table>
{% endblock %}
